import { scrollMixin } from "../../../utils/mixin";
// import lineEcharts from "./components/lineEcharts";
// import indexGroupItem from "./components/index_group_item";
// import qrcode from "./components/qrcode";
// import filterPopup from "./components/filter-popup";
// import inviterMemberItem from "./components/inviter-member-item";
// import sharePoster from "./components/share_poster";

import { Toast } from "vant";
export default {
  mixins: [scrollMixin], //加载更多
  //   components: { lineEcharts, indexGroupItem, qrcode, filterPopup, inviterMemberItem, sharePoster },
  data() {
    return {
      listData: [],
      page: 1, //分页数，当前页数
      isLoadMore: true, //判断是否要加载更多的标志
      total_page: 0, //总页数
      money:'',
      hongbao_money:'',
      pool:''
    };
  },
  activated() {
    window.scrollTo(0, 0);
    // this.getEmployee();
    this.getListData();
  },
  methods: {

    initData() {
      this.page = 1;
      this.isLoadMore = true;
      this.total_page = 0;
    },
    // 格式化时间戳
    timestampToDateTime(timestamp) {
      var date = new Date(timestamp * 1000); // JavaScript中的时间戳单位是毫秒，需要乘以1000才能正确显示

      var year = date.getFullYear();
      var month = ("0" + (date.getMonth()+1)).slice(-2); // 获取月份并补零
      var day = ("0" + date.getDate()).slice(-2); // 获取天数并补零
      var hours = ("0" + date.getHours()).slice(-2); // 获取小时并补零
      var minutes = ("0" + date.getMinutes()).slice(-2); // 获取分钟并补零
      var seconds = ("0" + date.getSeconds()).slice(-2); // 获取秒数并补零

      return year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds;
    },
    //获取更多数据
    getMoreData() {
      console.log('hongbao', this.isLoadMore);
      if (!this.isLoadMore) return;
      this.isLoadMore = false; // 防止多次请求分页数据
      if (this.page >= this.total_page) {
        return;
      } else {
        this.page += 1;
        let json = {
          uid: localStorage.getItem("uid"),
          page: this.page
        };
        let _url = "Feilong.user_list";
        $http.post(_url, json).then(response => {
          if (response.result === 1) {
            console.log(response.data, 'data');
            var nextPageData = response.data.list.data;
            // res.data.list.data
            //   var nextPageData = response.data.record_list.data;
            //   this.money_arr = Object.assign(this.money_arr, response.data.point_arr);
            // for (const key in nextPageData) {
            //     console.log(key,'llll')
            //     if (this.listData.data[key]) {
            //       this.$set(this.listData.data, key, [...this.listData.data[key], ...nextPageData[key]]);
            //     } else {
            //       this.$set(this.listData.data, key, nextPageData[key]);
            //     }
            //     // if (this.record_list.data[key]) {
            //     //   this.$set(this.record_list.data, key, [...this.record_list.data[key], ...nextPageData[key]]);
            //     // } else {
            //     //   this.$set(this.record_list.data, key, nextPageData[key]);
            //     // }
            // }
            this.listData = [...this.listData, ...nextPageData];
            this.isLoadMore = true;
            console.log(this.listData, 'ffdfdd');
            //   console.log(this.record_list.data);
          } else {
            this.page = this.page - 1;
            this.isLoadMore = false;
          }
        });
      }
    },

    // setTabIndex(index) {
    //   if (index == this.tabIndex) return;
    //   if (this.owner == null) this.getOwner();
    //   this.tabIndex = index;
    //   this.childTabIndex = this.tabIndex == 0 ? 0 : 3;
    //   this.getListData();
    // },
    // setChildTabIndex(index) {
    //   if (index == this.childTabIndex) return;
    //   this.childTabIndex = index;
    //   this.getListData();
    // },
    getListData() {
      Toast.loading({
        message: "",
        forbidClick: true
      });
      this.initData();
      let json = {
        uid: localStorage.getItem("uid"),
        page: this.page
      };
      let _url = "Feilong.user_list";

      // if (this.childTabIndex != 4) {
      //   json.owner_type = this.tabIndex;
      //   if (this.tabIndex == 0) {
      //     json.is_bind_owner_uid = this.childTabIndex;
      //   }
      //   if (this.searchText != "") {
      //     json.kwd = this.searchText;
      //   }
      //   _url = "plugin.group-develop-user.frontend.group-chat.get-list";
      // }

      // if (this.tabIndex == 1 && this.childTabIndex == 4) {
      //   json.member_name = this.searchMemberName; //会员昵称
      //   json.group_name = this.searchText; //群名称
      //   if (this.filterConfig) {
      //     for (let key in this.filterConfig) {
      //       console.log(key + "---");
      //       json[key] = this.filterConfig[key].value;
      //     }
      //     console.log("wwwwwwwwwwwww", json);
      //   }
      //   _url = "plugin.group-develop-user.frontend.group-chat-member.inviterGetList";
      // }

      $http.get(_url, json).then(res => {
        Toast.clear();
        if (res.result !== 1) {
          Toast(res.msg);
          return;
        }

        this.listData = res.data.list.data;
        this.hongbao_money = res.data.money;
        this.pool = res.data.pool;
        console.log(this.listData, 'this.listDataaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
        this.isLoadMore = true;
        this.total_page = res.data.list.last_page;
        if (!this.total_page) {
          this.total_page = 0;
        }

        console.log(this.hongbao_money,res.data.money);
      });
    },

  }
};
